// Package decleration
package basicversion;

public class Main {
    
    /** 
     * Trajectory Equation. Takes a y value in meters
     * deg value in degrees (as people can visualize it)
     * v value which is velocity in m/s
     * g value which is gravity
     * Returns a double which is the x value which is not 0.
     * 
     */
    
    private static double trajectory(double y,double deg,double v, double g) {
        
        // Convert degrees to radians using the constant
        double phi = deg * 0.0174532925;
        
        // A,B,C values correspond to (-B +/- (B^2 - 4AC))/2A
        // the quadratic root equation
        
        double A = ((-g)/(v * v * Math.pow(Math.cos(phi),2)));
        double B = Math.tan(phi);
        double C = y;
        
        // Two outputs for + and -
        
        double x1 = ((-B + Math.sqrt(B*B - (4*A*C)))/ (2*A));
        double x2 = ((-B - Math.sqrt(B*B - (4*A*C)))/ (2*A));
        
        // In this case one will always be 0 so find the one which is
        // and return the other.
        
        if(x1 == 0.0) return x2;
        else return x1;
    }
    
    // Main. Takes the input velocity and Degrees and prints
    // the range.
    
    public static void main(String[] args) {
        double v = Double.parseDouble(args[0]);
        double phi = Double.parseDouble(args[1]);
        
        // y is always 0 as in this we have flat ground.
        // g is happy in 9.81 m/s
        
        System.out.println(trajectory(0.0d,phi,v,9.81));
    }
}
